package com.ycl.web.backend;

import com.ycl.model.EbComment;
import com.ycl.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/guestbook")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 留言分页查询
     * @param model
     * @return
     */
    @RequestMapping("/list")
    public String list(Model model,
                              @RequestParam(value = "page",defaultValue = "1")Integer page,
                              @RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize){
        List<EbComment> ebComments = commentService.list(page, pageSize);
        model.addAttribute("ebComments",ebComments);
        return "manage/guestbook";
    }
}
